package com.kebabeaters.nakebab.client.ui.widget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.shared.SafeUri;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class UserReviewWidget extends Composite {

	public interface Binder extends UiBinder<Widget, UserReviewWidget> {
	}

	private Binder uiBinder = GWT.create(Binder.class);

	private final Widget widget;

	@UiField
	protected Image avatar;
	@UiField
	protected InlineLabel name;
	@UiField
	protected InlineLabel date;
	@UiField
	protected Label avgMark;
	@UiField
	protected Label description;
	@UiField
	protected Label meatMark;
	@UiField
	protected Label vegetablesMark;
	@UiField
	protected Label sauceMark;
	@UiField
	protected Label breadMark;
	@UiField
	protected Label priceForSizeMark;
	@UiField 
	protected InlineLabel plus;
	@UiField
	protected InlineLabel minus;
	
	public UserReviewWidget() {
		widget = uiBinder.createAndBindUi(this);
		initWidget(widget);
		
		
	}

	public void setName(String name) {
		this.name.setText(name);
	}

	public void setDate(String date) {
		this.date.setText(date);
	}

	// assume, that no value is null
	public void setMarks(double meatMark, double breadMark,
			double vegetablesMark, double priceForSizeMark, double sauceMark) {
		double avg = (meatMark + breadMark + vegetablesMark + priceForSizeMark + sauceMark) / 5;

		avgMark.setText(Double.toString(avg));

		this.breadMark.setText(Double.toString(breadMark));
		this.priceForSizeMark.setText(Double.toString(priceForSizeMark));
		this.vegetablesMark.setText(Double.toString(vegetablesMark));
		this.meatMark.setText(Double.toString(meatMark));
		this.sauceMark.setText(Double.toString(sauceMark));
	}

	public void setDescription(String description) {
		this.description.setText(description);
	}

	public void setImageUrl(String imageUrl) {
		avatar.setUrl(imageUrl);
	}

	public void setImageUrl(SafeUri safeUri) {
		avatar.setUrl(safeUri);
	}
	
	public void setPlus(int plus) {
		this.plus.setText(plus + "+");
	}
	
	public void setMinus(int minus) {
		this.minus.setText("-" + minus);
	}
}
